@extends('layouts.admin')
@section('title') @parent 商品管理 @stop
@section('page_title')@parent
添加商品
@show
@section('breadcrumb')@parent
{{ Breadcrumbs::render('product-edit') }}
@show
@section('content')
<div class="row">
    <div class="col-xs-12">
        <div class="box">
            <div class="box-header">
                <h3 class="box-title">添加商品</h3>
                
            </div><!-- /.box-header -->
            <form fole="form" method="post" action="{{ route('admin.product.add') }}" enctype="multipart/form-data">
            <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
            <div class="box-body">
                <div class="form-group">
                    <label for="cat_sort">分类</label>
                    <select class="form-control" id="product_category" name="data[category_id]">
                    @foreach($categories as $cat)
                    <option value="{{ $cat->id }}"  >{{ $cat->title }}</option>
                    @endforeach
                    </select>
                </div>
                <div class="form-group">
                    <label for="cat_title">标题</label>
                    <input type="text" name="data[name]" id="cat_title" placeholder="标题" value="" class="form-control"/>
                </div>
                <div class="form-group">
                    <label for="cat_title">库存</label>
                    <input type="number" name="data[stock]" id="cat_title" placeholder="库存" value="-1" />
                </div>
                <div class="form-group">
                    <label for="cat_title">价格</label>
                    <input type="text" name="data[price]" id="cat_title" placeholder="价格" value="1" />元
                </div>
                <div class="form-group">
                    <label for="score_cut">积分抵扣</label>
                    <input type="text" name="data[score_cut]" id="score_cut" placeholder="如商品价格100元，可以用积分抵扣其中10元，则输入10" value=""  class="form-control"/>
                </div>
				<div class="form-group">
                    <label for="is_recommend">是否推荐</label>
                    <input type="radio" name="data[is_recommend]" value="0" checked >否
					<input type="radio" name="data[is_recommend]" value="1" >是
                </div>
                <div class="form-group">
                    <label for="upload_pic">图片</label>
                    <input type="file" name="upload_pic" >
                </div>
                <div class="form-group">
                    <label for="upload_pic">商品简介</label>
                    <textarea rows="3" name="data[summary]" class="form-control"></textarea>
                </div>
                <div class="form-group">
                    <label for="upload_pic">商品介绍</label>
                    <textarea cols="80" rows="10" name="attribute[introduce]" id="product_introduct" style="visibility: hidden; display: none;" class="form-control"></textarea>
                </div>
					
				 <div class="form-group" id="cat_spec">                    
                </div>
                
            </div><!-- /.box-body -->
            <div class="box-footer">
                <button class="btn btn-primary" type="submit">保存</button>
            </div>
            </form>
        </div><!-- /.box -->
    </div>
</div>


@stop
@section('end')
@parent
{{ HTML::script("/ckeditor/ckeditor.js") }}
<script>
$(function() {
	CKEDITOR.replace('product_introduct'	, {
				height: 250,
				extraPlugins: 'colorbutton,colordialog',
				filebrowserBrowseUrl : '/ckfinder/ckfinder.html',
				filebrowserImageBrowseUrl : '/ckfinder/ckfinder.html?Type=Images',
				filebrowserFlashBrowseUrl : '/ckfinder/ckfinder.html?Type=Flash',
				filebrowserUploadUrl : '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
				filebrowserImageUploadUrl : '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
				filebrowserFlashUploadUrl : '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
	});

	$('#product_category').change(function(){
		var _url = "{{ route('admin.product.cat_spec',['id'=>':cat_id']) }}";
		var url = _url.replace(':cat_id', $(this).val() );
		$('#cat_spec').load(url);		
	});
	$('#product_category').find('option:eq(0)').attr('selected',true);
	$('#product_category').change();

});
</script>
@stop